//package com.ld.security.auth.server.config;
//
//import com.ld.security.auth.common.base.entity.JwtUser;
//import com.ld.security.auth.common.base.entity.JwtUserInfo;
//import com.ld.security.auth.server.base.auth.UserAuth;
//import com.ld.security.auth.server.modules.sys.entity.SysUser;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.security.core.authority.SimpleGrantedAuthority;
//import org.springframework.security.core.userdetails.User;
//import org.springframework.security.core.userdetails.UserDetails;
//import org.springframework.security.core.userdetails.UserDetailsService;
//import org.springframework.security.core.userdetails.UsernameNotFoundException;
//import org.springframework.stereotype.Component;
//
//import java.util.Arrays;
//import java.util.List;
//import java.util.stream.Collectors;
//
//@Component
//public class UserDetailsServiceImpl implements UserDetailsService {
//
//    @Autowired
//    UserAuth<SysUser> userAuth;
//
//    @Override
//    public UserDetails loadUserByUsername(String s) throws UsernameNotFoundException {
//        SysUser sysUser =  userAuth.findByUsername(s);
//        if(sysUser != null){
//            JwtUserInfo info =  userAuth.getJwtInfo(s);
//            JwtUser jwtUser =  info.getJwtUser();
//            List<SimpleGrantedAuthority> permissions =  info.getJwtPermissions().stream().map(val -> {
//                return new SimpleGrantedAuthority(val.getUrl());
//            }).collect(Collectors.toList());
//            User user = new User(jwtUser.getUsername(), jwtUser.getPassword(), permissions);
//            return user;
//        }
//        throw new UsernameNotFoundException("账户不存在");
//    }
//}
